<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>insert</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>

<div id="app">
    <form>
        姓名：<input type="text" v-model="user.userName"><br/>
        密码：<input type="text" v-model="user.password"><br/>
        email:<input type="email" v-model="user.email"><br/>
        tel:<input type="text" v-model="user.tel"><br/>
        <input @click="insert()" type="button" value="增加"/>
    </form>
</div>

<script>
    new Vue({
        el: '#app',
        data: {
            user:{
                userName:'',
                password:'',
                email:'',
                tel:''
            }
        },
        methods: {
            insert: function () {
                _this  = this;
                axios.post('/user/insert',_this.user).then(function (res) {

                    if (res != null){
                        window.location="index.html";
                    } else {
                        alert("你的操作有误，请重试");
                    }
                })
            }
        }
        
    })
</script>

</body>
</html>